package com.iss.demo.controller;
import com.iss.demo.entity.Contact;
import com.iss.demo.model.MyResponseData;
import com.iss.demo.service.ContactService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("contact/")
public class ContactController {

    @Autowired
    private ContactService service;

    @RequestMapping("selectAll")
    public List<Contact> selectAll(){
        List<Contact> list=service.selectAll();
        return list;
    }

    @RequestMapping("insertContact")
    public MyResponseData insertContact(Contact contact){
        Integer count = service.insertContact(contact);
        MyResponseData responseData = new MyResponseData();
        responseData.setErrorCode(0);
        responseData.setStatus("成功写入评论");
        return responseData;
    }
}
